<?php
	function create_follow_table()
	{
		global $wpdb;

		//create the name of the table including the wordpress prefix (wp_ etc)
		$search_table = $wpdb->prefix . "follow";
		//$wpdb->show_errors();

		//check if there are any tables of that name already
		if ($wpdb->get_var("show tables like '$search_table'") !== $search_table)
		{
			//create your sql
			$sql = "
            CREATE TABLE {$search_table} (
            follow_id MEDIUMINT (12) NOT NULL AUTO_INCREMENT,
            follow_what VARCHAR (20) NOT NULL,
            user_email VARCHAR (255) NOT NULL,
            VALUE VARCHAR (20) NOT NULL,
            TIME VARCHAR (20) NOT NULL,
            user_ip TEXT (20) NOT NULL,
            STATUS INT,
            UNIQUE KEY follow_id (follow_id),
            UNIQUE KEY email_value (user_email,VALUE)
            );
            ";
		}
		//include the wordpress db functions
		require_once (ABSPATH . 'wp-admin/upgrade-functions.php');
		dbDelta($sql);

		//register the new table with the wpdb object
		if (!isset($wpdb->follow))
		{
			$wpdb->follow = $search_table;
			//add the shortcut so you can use $wpdb->follow
			$wpdb->tables[] = str_replace($wpdb->prefix, '', $search_table);
		}
	}
	//add to front and backend inits
	add_action('init', 'create_follow_table');
?>